module.exports = function () {
  return function (ctx, next) {
    ctx.paginationResolve = function () {
      const query = ctx.method === 'GET' ? ctx.query : ctx.request.body || {}
      const limit = +(query.limit || 10)
      const offset = +(query.offset || 0)
      return {
        limit, offset
      }
    }
    return next()
  }
}
